<?php

/*
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$key = md5("secret");
$text = "U2FsdGVkX1+wiD6qhM4xdrsfHJ+pL1cZwwZQdic2PJI=";
echo strlen($text) . "\n";

$crypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($text),
   MCRYPT_MODE_ECB, $iv);
echo strlen($crypttext) . "\n";
echo $crypttext, "\n";
 */

class crypto {
   function __construct($key) {
      $this->ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
         MCRYPT_MODE_ECB);
      $this->iv = "0123456789ABCDEF";
      $this->key = md5($key);
      echo $this->key, "\n";
   }

   public function encrypt($InputString) {
      return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->key,
         $InputString, MCRYPT_MODE_ECB, $this->iv));
   }

   public function decrypt($InputString) {
      return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->key, base64_decode(
         $InputString), MCRYPT_MODE_ECB, $this->iv);
   }
}

$cipher = new crypto("secret");
$retval = $cipher->encrypt("This String");
printf("retval: %s\n", $retval);
printf("%s\n", $cipher->decrypt($retval));
?>
